package com.mike.fragmentdemo3.Fragment.Bean;

import android.os.Parcel;
import android.os.Parcelable;

public class MusicBean implements Parcelable {
    private String name;
    private String singer;
    private int sourceId;
    private int time;
    private int image;

    public MusicBean() {

    }

    public MusicBean(String name, String singer, int sourceId, int image) {
        this.name = name;
        this.singer = singer;
        this.sourceId = sourceId;
        this.image = image;
    }

    public int getImage() {
        return image;
    }

    public void setImage(int image) {
        this.image = image;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSinger() {
        return singer;
    }

    public void setSinger(String singer) {
        this.singer = singer;
    }

    public int getSourceId() {
        return sourceId;
    }

    public void setSourceId(int sourceId) {
        this.sourceId = sourceId;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeString(singer);
        dest.writeInt(sourceId);
        dest.writeInt(time);
        dest.writeInt(image);
        // ... 写入其他成员变量
    }

    // 创建一个 Creator 对象，用于从 Parcel 中创建 MyCustomObject 的实例
    public static final Creator<MusicBean> CREATOR = new Creator<MusicBean>() {
        @Override
        public MusicBean createFromParcel(Parcel in) {
            return new MusicBean(in);
        }

        @Override
        public MusicBean[] newArray(int size) {
            return new MusicBean[size];
        }
    };

    // 构造函数，用于从 Parcel 中创建实例
    protected MusicBean(Parcel in) {
        name = in.readString();
        singer = in.readString();
        sourceId = in.readInt();
        time = in.readInt();
        image = in.readInt();
        // ... 读取其他成员变量
    }
}
